/*
https://leetcode-cn.com/problems/implement-rand10-using-rand7/solution/yong-rand7-shi-xian-rand10-by-leetcode-s-qbmd/
*/

import java.util.Random;

public class Solution470 {
    public int rand10() {
        int result;
        do {
            int a = rand7();
            int b = rand7();
            result = (b - 1) * 7 + a;
        }while (result>40);
        return (result%10)+1;
    }

    public int rand7(){
        return new Random().nextInt(7)+1;
    }

    public static void main(String[] args) {
            System.out.println(new Solution470().rand10());
    }
}
